#!/usr/bin/env python3
# coding=utf-8

import rospy
from std_msgs.msg import String
from geometry_msgs.msg import Twist

count = 0
cmd = "Stop"

# 指令回调函数
def cmd_callback(msg):
    global cmd
    cmd = msg.data

# 主函数
if __name__ == "__main__":
    rospy.init_node("cmd_to_ros")
    # 订阅远程指令话题
    cmd_sub = rospy.Subscriber("cmd_dest",String,cmd_callback,queue_size=10)
    # 发布机器人运动控制话题
    vel_pub = rospy.Publisher("cmd_vel",Twist,queue_size=10)
    rate = rospy.Rate(10)
    while not rospy.is_shutdown():
        if cmd == "Stop":
            #rospy.logwarn("停止状态 ")
            vel_cmd = Twist()
            vel_cmd.angular.z = 0
            vel_cmd.linear.x = 0
            vel_pub.publish(vel_cmd)
            rate.sleep()